<?php
namespace App\Models\Goods;

use App\Contracts\Repositories\GoodsRepository;

class GoodsService
{
    private $goodsRepository;

    public function __construct(GoodsRepository $goodsRepository)
    {
        $this->goodsRepository = $goodsRepository;
    }

    public function getById($goodsId)
    {
        return $this->goodsRepository->findByConditions(array('id' => $goodsId), 'goodsRecord');
    }

    public function createGoods($goods)
    {
        return $this->goodsRepository->create($goods);
    }

    public function modifyGoods($goods, $conditions)
    {
        return $this->goodsRepository->modify($goods, $conditions);
    }

    public function deleteGoods($conditions, $softDeletion = false)
    {
        return $this->goodsRepository->delete($conditions, $softDeletion);
    }

    public function getByConditions($conditions, $withs)
    {
        return $this->goodsRepository->findByConditions($conditions, $withs);
    }
}
